home *** CD-ROM | disk | FTP | other *** search
/ Graphics Plus / Graphics Plus.iso / general / fractal / kaos.lha / tserlib / to_1d_tser.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-12-06  |  538 b   |  37 lines

  1. /*
  2. ### collapse multi-dim info to 1-d info ###
  3.  
  4. Input:    n: the dimension of  multi-dim info
  5.     is: switch for collapsing algorithms
  6. */
  7.  
  8. double to_1d_tser(x,n,is)
  9. int is,n;
  10. double *x;
  11. {
  12.     int i;
  13.     double y;
  14.     switch(is){
  15.         case 0:
  16.             y = 0;
  17.             for(i=0;i<n;i++)
  18.                 y += *(x+i);
  19.             break;
  20.         case 1:
  21.             y = 0;
  22.             for(i=0;i<n;i++)
  23.                 y += *(x+i) * *(x+i);
  24.             break;
  25.         case 2:
  26.             y = *x;
  27.             break;
  28.         default:
  29.             y = 0;
  30.             for(i=0;i<n;i++)
  31.                 y += *(x+i);
  32.             system_mess_proc(0,"Option not installed. Using default...");
  33.             break;
  34.     }
  35.     return(y);
  36. }
  37.